import { GSprite } from "../../../../com/mui/controls/GSprite";
import { SuitInfo } from "../../resource/info/SuitInfo";
import { ObjCreate } from "../common/ObjCreate";
import { SpiritSkillRenderer } from "./SpiritSkillRenderer";
import { DataProvider } from "../../../../fl/data/DataProvider";
import { TItemSuit } from "../../../../Message/Db/Tables/TItemSuit";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { GTileList } from "../../../../com/mui/controls/GTileList";
type int = number;
//class SuitAttributePanel
    
    export  class SuitAttributePanel extends GSprite
    {
        constructor()
        {
            super();
            this._suitAttTxtArr = [];
            return;
        }

        public updateSuitAtt(arg1: SuitInfo): void
        {
            this._suitInfo = arg1;
            if (this._suitInfo) 
            {
                this.removeAttTxt();
                this.addAttributeTxts(this._suitInfo.itemSuit);
            }
            return;
        }

        public updateSkillList(arg1: Array<any>): void
        {
            this._skillList.dataProvider.removeAll();
            this._skillList.dataProvider.addItems(arg1);
            return;
        }

        protected /* override */ createDisposedChildrenImpl(): void
        {
            this._skillList = ObjCreate.createTileList(190, 20, 200, 38, this);
            this._skillList.columnWidth = 47;
            this._skillList.rowHeight = 38;
            this._skillList.setStyle("cellRenderer", SpiritSkillRenderer);
            this._skillList.dataProvider = new DataProvider([]);
            return;
        }

        /* internal  */addAttributeTxts(arg1: TItemSuit): void
        {
            if (arg1.attr1 != "0") 
            {
                this.addAttTxt(arg1.attr1, 1);
            }
            if (arg1.attr2 != "0") 
            {
                this.addAttTxt(arg1.attr2, 2);
            }
            if (arg1.attr3 != "0") 
            {
                this.addAttTxt(arg1.attr3, 3);
            }
            if (arg1.attr4 != "0") 
            {
                this.addAttTxt(arg1.attr4, 4);
            }
            if (arg1.attr5 != "0") 
            {
                this.addAttTxt(arg1.attr5, 5);
            }
            if (arg1.attr6 != "0") 
            {
                this.addAttTxt(arg1.attr6, 6);
            }
            if (arg1.attr7 != "0") 
            {
                this.addAttTxt(arg1.attr7, 7);
            }
            if (arg1.attr8 != "0") 
            {
                this.addAttTxt(arg1.attr8, 8);
            }
            this.resetAttTxt();
            return;
        }

        /* internal  */addAttTxt(arg1: string, arg2: int): void
        {
            var loc1=ObjCreate.createGTextField("", 0, 0, 190, 20, this, GlobalStyle.textFormat3);
            this._suitAttTxtArr.push(loc1);
            loc1.htmlText = "(" + arg2 + ") " + this._suitInfo.parseAttr(arg1, "+");
            loc1.name = arg2 + "";
            return;
        }

        /* internal  */removeAttTxt(): void
        {
            var loc2=null;
            var loc1=this._suitAttTxtArr.length;
            var loc3=0;
            while (loc3 < loc1) 
            {
                loc2 = this._suitAttTxtArr[loc3];
                if (loc2 && loc2.parent) 
                {
                    loc2.dispose();
                }
                ++loc3;
            }
            this._suitAttTxtArr.splice(0);
            return;
        }

        /* internal  */resetAttTxt(): void
        {
            var loc2=null;
            var loc4=0;
            var loc1=this._suitAttTxtArr.length;
            var loc3=0;
            loc4 = 0;
            var loc5=0;
            while (loc5 < loc1) 
            {
                loc2 = this._suitAttTxtArr[loc5];
                loc2.x = loc3;
                loc2.y = loc4;
                loc4 = loc4 + 20;
                if (loc5 == 3) 
                {
                    loc2.x = 182;
                    loc2.y = 0;
                }
                ++loc5;
            }
            return;
        }

        /* internal  */addSkillList(arg1: Array<any>): void
        {
            if (arg1 == null) 
            {
                return;
            }
            var loc1=[];
            var loc2=0;
            while (loc2 < arg1.length) 
            {
                loc1.push({"skillId": arg1[loc2], "isEnable": false});
                ++loc2;
            }
            var loc3=new DataProvider(loc1);
            if (this._skillList == null) 
            {
                this._skillList = ObjCreate.createTileList(180, 20, 200, 38, this);
                this._skillList.columnWidth = 50;
                this._skillList.rowHeight = 38;
                this._skillList.setStyle("cellRenderer", SpiritSkillRenderer);
            }
            this._skillList.dataProvider = loc3;
            return;
        }

        public updateActiveNum(arg1: int): void
        {
            var loc1=0;
            var loc2=0;
            var loc3=null;
            if (this._suitInfo) 
            {
                loc1 = this._suitAttTxtArr.length;
                loc2 = 0;
                while (loc2 < loc1) 
                {
                    if ((loc3 = this._suitAttTxtArr[loc2]) && loc3.parent) 
                    {
                        if (parseInt(loc3.name) <= arg1) 
                        {
                            loc3.textColor = 16776960;
                        }
                        else 
                        {
                            loc3.textColor = 10066329;
                        }
                    }
                    ++loc2;
                }
            }
            return;
        }

        /* internal */ /* var */_suitAttTxtArr: Array<any>;

        /* internal */ /* var */_suitInfo: SuitInfo;

        /* internal */ /* var */_skillList: GTileList;
    }
